obj = {
	add:function () {
		var awin = $('#addStateWin');
		awin.panel({title: "新增状态"}).dialog("open");
	},
	edit:function(){
		  var node = $('#equipState_data').datagrid('getSelected');
		  if(node!=null){
		  	  var ewin = $('#editStateWin');
			  $.post(basePath+"/equipState/load.json",{'id':node.id},function(res){
			  		ewin.form('load', {
			  			stateType : res.data.stateType,
			  			highValue : res.data.highValue,
			  			lowValue : res.data.lowValue,
						id:res.data.id
					}).dialog('open');
			  });
		  }else{
			  $.messager.alert("提示信息","请选择一条记录!");
		  }
	},
	deletes:function(){
		var node = $('#equipState_data').datagrid('getSelected');
		if(node!=null){
			$.post(basePath+"/equipState/delete.json",{"id":node.id},function(data){
				if(data.success){
					$('#equipState_data').datagrid('reload');
				}else{
					$.messager.alert({showSpeed:100,title:'消息提示',msg:data.msg,timeout:3000});
				}
			});
		}else{
			$.messager.alert("提示信息","请选择一条记录!");
		}
	}
	
};
	
$(function(){
	$('#equipState_data').datagrid({
	    url: basePath+"/equipState/findAll.json",
	    method: 'get',
	    striped : true,
		nowrap : true,
		rownumbers : true,
		pagination: true,
		fitColumns : true,
		singleSelect:true,
		border:false,
		toolbar:'#tb_sb',
		scrollbarSize:1,
		pageSize: 2,
		 pageList: [2,5,10,20],
//		title:'设备',
	    columns:[[
	    	{field:'stateType',align:'center','title':'设备状态类型',width:200},
	    	{field:'lowValue',align:'center','title':'功率最低值',width:200},
			{field:'highValue',align:'center','title':'功率最高值',width:200}
	    ]],
	    pagination : true,
  		pageList : [5,10],
  		pageNumber : 1,
		pageSize : 10,
  		pagePosition : 'bottom'
	});
	
	
	
	//添加
	$('#addStateWin').dialog({
		width:400,
		height:300,
		iconCls:'icon-add',
		closed: true,
		modal: true,
		inline:true,
		buttons:[{
			text:'提交',
			iconCls:'icon-add-new',
			handler:function(){
				if($('#addStateform').form('validate')){
//					alert($("#add_lowValue").text());
					$.post(basePath+"/equipState/save.json",$("#addStateform").serialize(),function(data){
						if(data.success){
							$('#addStateWin').dialog('close');
							$('#equipState_data').datagrid('reload');
						}else{
							$.messager.alert({showSpeed:100,title:'消息提示',msg:data.msg,timeout:3000});
						}
					});
				}
			}
		},{
			text:'取消',
			iconCls:'icon-redo',
			handler:function(){
				$('#addStateWin').dialog('close');
			}
		}],
		onClose: function() {
			$('#addStateform').form('reset');
		}
	});
	
	//编辑
	$('#editStateWin').dialog({
		title:'编辑',
		width:400,
		height:300,
		iconCls:'icon-edit',
		closed: true,
		modal: true,
		inline:true,
		buttons:[{
			text:'提交',
			iconCls:'icon-add-new',
			handler:function(){
				if($('#editStateform').form('validate')){
					$.post(basePath+"/equipState/update.json",$("#editStateform").serialize(),function(data){
						if(data.success){
							$('#editStateWin').dialog('close');
							$('#equipState_data').datagrid('reload');
						}else{
							$.messager.alert({showSpeed:100,title:'消息提示',msg:data.msg,timeout:3000});
						}
					});
				}
			}
		},{
			text:'取消',
			iconCls:'icon-redo',
			handler:function(){
				$('#editStateWin').dialog('close');
			}
		}],
		onClose: function() {
			$('#editStateform').form('reset');
		}
	});
	
	
});
